package main

import (
	"fmt"
	"google.golang.org/grpc"
	"net"
	"os"
	"os/signal"
	rongyun_register_user "selfService/融云相关/service"
	"syscall"
)

func main() {
	interService := grpc.NewServer()
	// 注册融云服务相关的rpc服务
	rongyun_register_user.RegisterInterestServiceServer(interService,new(rongyun_register_user.RongyunServiceImpl))

	lis,err:=net.Listen("tcp","localhost:8085")
	if err!=nil{
		panic(err)
	}
	// 携程启动
	go func() {
		fmt.Println("调用")
		if err:=interService.Serve(lis);err!=nil{panic(err)}
	}()
	// 自动优雅暂停
	c := make(chan os.Signal,1)
	signal.Notify(c,syscall.SIGHUP,syscall.SIGQUIT,syscall.SIGTERM,syscall.SIGINT)
	for{
		s:= <-c
		switch s {
		case syscall.SIGQUIT,syscall.SIGTERM,syscall.SIGINT:
			interService.GracefulStop()
			return
		}
	}
}
